package com.self.starter.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@ConfigurationProperties(prefix = "spring.self.props")
public class PropsController {

    private static final String SELF_PROPS_NAME = "spring.self.props.name";
    @Autowired
    private Environment env;

    @Value("${spring.self.props.name}")
    private String props2;

    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @GetMapping("props/ways/1")
    public String props1() {
        return env.getProperty(SELF_PROPS_NAME);
    }

    @GetMapping("props/ways/2")
    public String props2() {
        return props2;
    }

    @GetMapping("props/ways/3")
    public String props3() {
        return name;
    }
}
